<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="../../js/mui.min.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <link href="../../css/mui.min.css" rel="stylesheet"/>
    <link rel="stylesheet" type="text/css" href="../../css/own.css"/>
    <script type="text/javascript" charset="UTF-8">
    
    	
      	mui.init({
			pullRefresh: {      
			    container: "#pullrefresh",//待刷新区域标识
			    up : {
			      contentrefresh: "正在加载...",//可选，正在加载状态时，上拉加载控件上显示的标题内容
			      callback: listmore, //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
			    }
			 } 
		});
		var ftrade_list=null;
		var ftrade_list_num=0;
		mui.plusReady(function(){
			var dataUrl={
				home:"cp.html",
  				account:"../account/account.html",
  				accountno:"../account/accountno.html",
  				scheme:"../scheme.html",
  				listrg:"listrg.html",
  				quotationMain:"../quotation/quotationMain.html",
  			}
			initBottom(dataUrl);
			//加载方案信息
			var paramUrl={
				url:"../login/login.html"
			}
			mui.app_request("/user/ftrade/list",{},function(result){
				if(!mui.isnull(result.data)){
					ftrade_list=result.data.tradeList;
					mui.each(ftrade_list,function(i,item){
						if(i<6){
							addlistNO(item);
							ftrade_list_num++;
						}
						
					});
					
				//绑定li点击事件
				mui("#list_ul").on("tap","li",function(){
					var id=this.getAttribute("id");
					if("no_list"==id){
						return;
					}
					var businessType=this.getElementsByTagName("span")[0].innerHTML;
						
						var new_url=null;
						if("富时A50"==businessType){
							new_url="DetailCn.html";
						}else if("国际原油"==businessType){
							new_url="DetailCl.html";
						}else if("恒指期货"==businessType){
							new_url="DetailHsi.html";
						}else if("国际综合"==businessType){
							new_url="DetailCp.html";
						}else{
							new_url="../login/login.html";
						}
						
						//点击跳转开户或开户失败方案详情页
						mui.openWindow({
							url:new_url,
							id:new_url,
							extras:{
								did:id  
							}
						});

				});
		
				}
				if(mui.isnull(result.data.tradeList)){
					document.getElementById("no_list").style.display="block";
				}
					
				
			},function(result){
				mui.toast(result.message);
				return;
			},paramUrl);
			

		});
		
		
		//加载更多  
		  function listmore(){
		  	
		  	if(!mui.isnull(ftrade_list)&&ftrade_list.length>6){
		  		
		  		var isnum=(ftrade_list.length-(ftrade_list_num+6)) >=0 ? true : false;
		  		
		  		if(isnum){
		  			 
		  			//每次加载十条
			  		for(var i=0;i<6;i++){
			  			addlistNO(ftrade_list[ftrade_list_num]);  
			  			ftrade_list_num++;
			  		}
			  		mui('#pullrefresh').pullRefresh().endPullupToRefresh(false);
		  		}else{
		  			var list_n=ftrade_list.length-ftrade_list_num;
		  			//最后不足十条
			  		for(var i=0;i<list_n;i++){
			  			addlistNO(ftrade_list[ftrade_list_num]);
			  			ftrade_list_num++;
			  		}
			  		
			  		mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
			  		
		  		}
		  		
		  		
		  	}else{
		  		
		  		mui('#pullrefresh').pullRefresh().endPullupToRefresh(true);
		  	}
		  }
		
		
		
		function addlistNO(ftrade_list){
			var list_ul=document.getElementById("list_ul");
			
			if(mui.isnull(ftrade_list.stateType)){
				return;
			}
			
			var li=document.createElement("li");
			li.setAttribute("id",ftrade_list.id);
			var p=document.createElement("p");
			p.setAttribute("class","sc_statusfont");
			var img=document.createElement("img");
			switch(ftrade_list.stateType){
				case 1:
					li.setAttribute("class","mui-table-view-cell sc_open");
					img.setAttribute("src","../../images/status_01.png");
					
				break;
				case 4:
					li.setAttribute("class","mui-table-view-cell sc_trade");
					img.setAttribute("src","../../images/status_03.png");
					
				break;
				case 2:
					li.setAttribute("class","mui-table-view-cell sc_trade");
					img.setAttribute("src","../../images/status_03.png");
					
				break;
				case 3:
					li.setAttribute("class","mui-table-view-cell sc_trade");
					img.setAttribute("src","../../images/status_03.png");
					
				break;
				case 5:
					li.setAttribute("class","mui-table-view-cell sc_fail");
					img.setAttribute("src","../../images/status_02.png");
				
				break;
				case 6:
					li.setAttribute("class","mui-table-view-cell sc_fail");  
					img.setAttribute("src","../../images/status_04.png");
					
				break;
			}
			
			p.appendChild(img);
			var h4=document.createElement("h4");
			h4.innerHTML=tzdr.dateUtil.getFormatDataByLong(ftrade_list.appTime,"yyyy-MM-dd hh:mm");
			
			var div_1=document.createElement("div");
			div_1.setAttribute("class","sc_data");
			
			var label_1=document.createElement("label");
			var span_1=document.createElement("span");
			var label_2=document.createElement("label");
			var span_2=document.createElement("span");
			label_1.innerHTML="交易品种";
			label_2.innerHTML="开仓手数";
			
			if(mui.isnull(ftrade_list.tranLever)){
				span_2.innerHTML=" 手";  
			}else{
				span_2.innerHTML=ftrade_list.tranLever+"手";
			}
			
			
			switch (ftrade_list.businessType){
				case 0:
					span_1.innerHTML="富时A50";
					break;
				case 6:
					span_1.innerHTML="国际原油";
					break;
				case 7:
					span_1.innerHTML="恒指期货";
					break;
				case 8:
					span_1.innerHTML="国际综合";
					span_2.innerHTML="无限制";
					break;
				default:
					break;
			}
			
			
			
			var div_2=document.createElement("div");
			div_2.setAttribute("class","sc_money");
			
			var label_3=document.createElement("label");
			var span_3=document.createElement("span");
			var label_4=document.createElement("label");
			var span_4=document.createElement("span");
			label_3.innerHTML="总操盘资金";
			label_4.innerHTML="亏损平仓线";
			span_3.innerHTML=tzdr.moneyUtils.formatCurrency(ftrade_list.traderTotal)+"美元";
			span_4.innerHTML=tzdr.moneyUtils.formatCurrency(ftrade_list.lineLoss)+"美元";
			
			
			var br_1=document.createElement("br");
			var br_2=document.createElement("br");
			
			div_1.appendChild(label_1);
			div_1.appendChild(span_1);
			div_1.appendChild(br_1);
			div_1.appendChild(label_2);
			div_1.appendChild(span_2);
			
			div_2.appendChild(label_3);
			div_2.appendChild(span_3);
			div_2.appendChild(br_2);
			div_2.appendChild(label_4);
			div_2.appendChild(span_4);
			
			li.appendChild(h4);
			li.appendChild(div_1);
			li.appendChild(div_2);
			li.appendChild(p);
			list_ul.appendChild(li);
			 
		};
    </script>
</head>
<body>
		<nav class="navlist">
		<a class="" href="javascript:void(0);" id="quotationMain" >
			<!--<span class="mui-icon mui-icon-settings"></span>-->
			<span class="mui-icon"><img src="../../images/0.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label">行情交易</span>
		</a>
		<a class="" href="javascript:void(0);"  id="product">
			<span class="mui-icon"><img src="../../images/1.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label">操盘申请</span>
		</a>
		<a class="navon" href="javascript:void(0);"  id="scheme">
			<span class="mui-icon"><img src="../../images/2.0.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label">操盘记录</span>
		</a>
		<a class="" id="account" href="javascript:void(0);">
			<span class="mui-icon"><img src="../../images/3.png" style="width: 20px;height:20px;"></span>
			<span class="mui-tab-label" >账户</span>
		</a>
	</nav>
<!--下拉刷新容器-->
		<div id="pullrefresh" class="mui-content mui-scroll-wrapper" style="padding-top: 20px;">
			<div class="mui-scroll sc_list">
				<!--数据列表-->
				<ul class="mui-table-view mui-table-view-chevron"  id="list_ul">
					<li style="display: none;" id="no_list">						
						<img src="../../images/list_02.png" />
						<span>暂无操盘方案记录，赶快去申请吧！</span>
					</li>
				</ul>
			</div>
		</div>

	
</body>
</html>